from gglib.auth import login_required
from gglib.packet import Packet
from gglib.user import User


@login_required
def handle(session, packet):
    new_pkt = Packet(packet)
    new_pkt.sender = session.user.username
    try:
        receiver = User.manager[packet.receiver]
        receiver.session.route_packet(new_pkt)
    except:
        pass
    session.route_packet(packet)
